<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>
      oos4ruby
  </title>
  <script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
<style>

</style>
  <script type="text/javascript">
    window.onload = function() {
      settings = {
          tl: { radius: 10 },
          tr: { radius: 10 },
          bl: { radius: 10 },
          br: { radius: 10 },
          antiAlias: true,
          autoPad: true,
          validTags: ["div"]
      }
      var versionBox = new curvyCorners(settings, document.getElementById("version"));
      versionBox.applyCornersToAll();
    }
  </script>
</head>
<body>
<div id="main">

    <h1>oos4ruby</h1>
    <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/oos4ruby"; return false'>
      <p>Get Version</p>
      <a href="http://rubyforge.org/projects/oos4ruby" class="numbers">0.2.1</a>
    </div>
<h2>What</h2>
<p>oos4ruby is a ruby library to interact with the 11870 <span class="caps">API</span>.</p>
<h2>Installing</h2>
<p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">oos4ruby</span></pre></p>
<h2>The basics</h2>
<p>The class &#8220;Oos4ruby::Oos&#8221; is the endpoint to interact with the api. This class provides the authentication methods in addition to the search and user management methods.</p>
<p><pre class='syntax'><span class="ident">oos</span> <span class="punct">=</span> <span class="constant">Oos4ruby</span><span class="punct">::</span><span class="constant">Oos</span><span class="punct">.</span><span class="ident">new</span></pre></p>
<p>Authenticate as an application in order to perform searches or explore the user contents:</p>
<p><pre class='syntax'><span class="ident">oos</span><span class="punct">.</span><span class="ident">auth_app</span> <span class="punct">'</span><span class="string">your appToken</span><span class="punct">',</span> <span class="punct">'</span><span class="string">your secret key</span><span class="punct">'</span></pre></p>
<p>Authenticate as a user in order to manage his contents:</p>
<p><pre class='syntax'><span class="ident">oos</span><span class="punct">.</span><span class="ident">auth_user</span> <span class="punct">'</span><span class="string">user email in 11870.com</span><span class="punct">',</span> <span class="punct">'</span><span class="string">user authorization token</span><span class="punct">'</span></pre></p>
<p>Method to perform a search inside 11870:</p>
<p><pre class='syntax'><span class="ident">oos</span><span class="punct">.</span><span class="ident">search</span> <span class="symbol">:q</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">cheap restaurants in new york</span><span class="punct">'</span></pre></p>
<p>How to obtain the services or places saved by a user:</p>
<p><pre class='syntax'>
<span class="comment">#if your app is authenticated with this user authorization token</span>
<span class="ident">user</span> <span class="punct">=</span> <span class="ident">oos</span><span class="punct">.</span><span class="ident">user</span>
<span class="comment">#if your app is authenticated to expore contents</span>
<span class="ident">user</span> <span class="punct">=</span> <span class="ident">oos</span><span class="punct">.</span><span class="ident">user</span> <span class="punct">'</span><span class="string">user slug in 11870</span><span class="punct">'</span>

<span class="ident">sites</span> <span class="punct">=</span> <span class="ident">user</span><span class="punct">.</span><span class="ident">sites</span>
</pre></p>
<p>How to add a review from a site that doesn&#8217;t exist in 11870:</p>
<p><pre class='syntax'>
<span class="ident">oos</span><span class="punct">.</span><span class="ident">user</span><span class="punct">.</span><span class="ident">sites</span><span class="punct">.</span><span class="ident">create!</span> <span class="punct">{</span><span class="symbol">:title</span> <span class="punct">=&gt;</span> <span class="punct">&quot;</span><span class="string">this site doesn't exist</span><span class="punct">&quot;,</span> 
    <span class="symbol">:user_address</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">the address</span><span class="punct">',</span> 
    <span class="symbol">:locality</span> <span class="punct">=&gt;</span> <span class="punct">{</span><span class="symbol">:name</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">Madrid</span><span class="punct">',</span> <span class="symbol">:slug</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">/es/madrid</span><span class="punct">'},</span>
    <span class="symbol">:country</span> <span class="punct">=&gt;</span> <span class="punct">{</span><span class="symbol">:name</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">España</span><span class="punct">',</span> <span class="symbol">:slug</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">/es</span><span class="punct">'}</span> 
    <span class="symbol">:summary</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">review title</span><span class="punct">',</span> <span class="symbol">:content</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">review content</span><span class="punct">'</span>
    <span class="symbol">:tags</span> <span class="punct">=&gt;</span> <span class="punct">['</span><span class="string">tapas</span><span class="punct">',</span> <span class="punct">'</span><span class="string">tipical spanish</span><span class="punct">'],</span> <span class="symbol">:lists</span> <span class="punct">=&gt;</span> <span class="punct">['</span><span class="string">food</span><span class="punct">']}</span>
</pre></p>
<p>How to add a review from a site that exists in 11870:</p>
<p><pre class='syntax'>
<span class="ident">oos</span><span class="punct">.</span><span class="ident">user</span><span class="punct">.</span><span class="ident">sites</span><span class="punct">.</span><span class="ident">create!</span> <span class="punct">{</span><span class="symbol">:id</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">11870 site id</span><span class="punct">',</span>
    <span class="symbol">:summary</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">review title</span><span class="punct">',</span> <span class="symbol">:content</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">review content</span><span class="punct">'}</span>
</pre></p>
<p>How to obtain all user contacts in 11870:</p>
<p><pre class='syntax'><span class="ident">contacts</span> <span class="punct">=</span> <span class="ident">user</span><span class="punct">.</span><span class="ident">contacts</span></pre></p>
<p>How to obtain the multimedia feed associated with a review:</p>
<p><pre class='syntax'><span class="ident">media_collection</span> <span class="punct">=</span> <span class="ident">user</span><span class="punct">.</span><span class="ident">sites</span><span class="punct">[</span><span class="number">0</span><span class="punct">].</span><span class="ident">multimedia</span></pre></p>
<p>How to add a new image or video to a review:</p>
<p><pre class='syntax'><span class="ident">user</span><span class="punct">.</span><span class="ident">sites</span><span class="punct">[</span><span class="number">0</span><span class="punct">].</span><span class="ident">multimedia</span><span class="punct">.</span><span class="ident">create!</span> <span class="punct">{</span>
  <span class="symbol">:file</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">image.png</span><span class="punct">',</span>
  <span class="symbol">:content_length</span> <span class="punct">=&gt;</span> <span class="constant">File</span><span class="punct">.</span><span class="ident">size</span><span class="punct">('</span><span class="string">image.png</span><span class="punct">'),</span>
  <span class="symbol">:content_type</span> <span class="punct">=&gt;</span> <span class="punct">'</span><span class="string">image/png</span><span class="punct">'</span>
<span class="punct">}</span>
</pre></p>
<h2>Forum</h2>
<p><a href="http://groups.google.com/group/api-11870">http://groups.google.com/group/api-11870</a></p>
<h2>How to submit patches</h2>
<p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people&#8217;s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the Google Group above.</p>
<p>The trunk repository is <code>http://api-11870.googlecode.com/svn/trunk/oos4ruby</code> for anonymous access.</p>
<h2>License</h2>
<p>This code is free to use under the terms of the <span class="caps">BSD</span> license.</p>
<h2>Contact</h2>
<p>Comments are welcome. Send an email to <a href="mailto:david.calavera@gmail.com">David Calavera</a> email via the <a href="http://groups.google.com/group/api-11870">forum</a></p>
    <p class="coda">
      <a href="http://thinkincode.net">David Calavera</a>, 19th November 2009<br>
      Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
    </p>
</div>

<!-- insert site tracking codes here, like Google Urchin -->

</body>
</html>
